summaryrefslogtreecommitdiff
path: root/src/pages/shop/brands/[slug].jsx
blob: f577e2c06dfc7730f6c75ac60b762c5511e53e25 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import dynamic from 'next/dynamic';
import { getIdFromSlug, getNameFromSlug } from '@/core/utils/slug';
import { useRouter } from 'next/router';
import _ from 'lodash';
import Seo from '@/core/components/Seo';
import Breadcrumb from '@/lib/brand/components/Breadcrumb';
import useBrand from '@/lib/brand/hooks/useBrand';
import PageNotFound from '@/pages/404';

const BasicLayout = dynamic(() =>
  import('@/core/components/layouts/BasicLayout')
);
const ProductSearch = dynamic(() =>
  import('@/lib/product/components/ProductSearch')
);
const Brand = dynamic(() => import('@/lib/brand/components/Brand'));

export default function BrandDetail() {
  const router = useRouter();
  const { slug = '' } = router.query;

  const brandName = getNameFromSlug(slug);
  const id = getIdFromSlug(slug);
  const { brand } = useBrand({ id });
  // if ( !brand.isLoading && _.isEmpty(brand.data)) {
  //   console.log('ini masuk pak')
  //   return <PageNotFound />;
  // }
  return (
    <BasicLayout>
      {/* <Seo
        title={`Jual Produk Resmi ${brandName} Indonesia | Indoteknik.com`}
        description='B2B Marketplace MRO &amp; Industri dengan Layanan Pembayaran Tempo, Faktur Pajak, Online Quotation, Garansi Resmi &amp; Harga Kompetitif'
        additionalMetaTags={[
          {
            property: 'keywords',
            content: `Jual ${brandName}, beli ${brandName}, Distributor ${brandName} Indonesia, cari ${brandName}, produk ${brandName}, ${brandName} Indonesia, harga ${brandName}`
          }
        ]}
      /> */}
      <Seo
        title={`Jual Produk Resmi ${brandName} Indonesia | Indoteknik.com`}
        description='B2B Marketplace MRO &amp; Industri dengan Layanan Pembayaran Tempo, Faktur Pajak, Online Quotation, Garansi Resmi &amp; Harga Kompetitif'
        additionalMetaTags={[
          {
            property: 'keywords',
            content: `Jual ${brandName}, beli ${brandName}, Distributor ${brandName} Indonesia, cari ${brandName}, produk ${brandName}, ${brandName} Indonesia, harga ${brandName}`,
          },
        ]}
        // canonical={`${process.env.NEXT_PUBLIC_SELF_HOST}/shop/brands/${slug}`}
        canonical={`${process.env.NEXT_PUBLIC_SELF_HOST}${
          router.asPath.split('?')[0]
        }`}
      />

      <Breadcrumb brandName={brandName} />

      <Brand brand={brand} />
      {!_.isEmpty(router.query) && (
        <ProductSearch
          query={_.omit(router.query, 'slug')}
          prefixUrl={`/shop/brands/${slug}`}
          defaultBrand={getNameFromSlug(slug)}
          brand={brand}
        />
      )}
    </BasicLayout>
  );
}